<template>
  <div class="main-container">
    <div class="sign-container">
      <div class="sign-title">
        <div class="bigTitle">知乎者也</div>
        <div class="subtitle">有问题就会有答案</div>
      </div>
      <div class="sign-form">
        <div class="form-left">
          <div class="appTips">打开知乎App</div>
          <div class="tips">在「我的页」左上角打开扫一扫</div>
          <div class="Qrcode-content">
            <div class="Qrcode-img">
              <img
                src="//www.zhihu.com/api/v3/account/api/login/qrcode/OGJmMWRmMjgtZTVl/image"
                alt=""
              />
            </div>

            <span class="appTips">其他扫码方式：微信</span>
          </div>
          <div class="button-group">
            <a-button class="other-btn">下载知乎App</a-button>
            <a-button class="other-btn">开通机构号</a-button>
            <a-button class="other-btn">无障碍模式</a-button>
          </div>
        </div>
        <div class="form-right">
          <a-tabs v-model:activeKey="activeKey">
            <a-tab-pane key="1" tab="验证码登录">
              <a-form
                :model="codeState"
                name="loginForm"
                :label-col="{ span: 0 }"
                :wrapper-col="{ span: 24 }"
                autocomplete="off"
                class="loginForm"
              >
                <a-form-item
                  name="phone"
                  :rules="[{ required: true, message: '请输入手机号！' }]"
                >
                <a-input
                    v-model:value="codeState.phone"
                    placeholder="手机号"
                  />
                </a-form-item>

                <a-form-item
                  name="code"
                  :rules="[{ required: true, message: '请输入验证码！' }]"
                  class="codeIpt"
                >
                  <a-input
                    v-model:value="codeState.code"
                    placeholder="输入6位短信验证码"
                  />
                  <span class="font-blue">获取短信验证码</span>
                </a-form-item>
                <div class="btn-group">
                  <span class="font-light">获取语音验证码</span>
                </div>
                <a-form-item :wrapper-col="{ span: 24 }">
                  <a-button type="primary" html-type="submit" class="submitBtn" 
                    >登录/注册</a-button
                  >
                </a-form-item>
              </a-form>
            </a-tab-pane>
            <a-tab-pane key="2" tab="密码登录" force-render>
              <a-form
                :model="formState"
                name="loginForm"
                :label-col="{ span: 0 }"
                :wrapper-col="{ span: 24 }"
                autocomplete="off"
                class="loginForm"
              >
                <a-form-item
                  name="username"
                  :rules="[{ required: true, message: '请输入手机号或邮箱！' }]"
                >
                  <a-input
                    v-model:value="formState.username"
                    placeholder="手机号或邮箱"
                  />
                </a-form-item>

                <a-form-item
                  name="password"
                  :rules="[{ required: true, message: '请输入密码！' }]"
                >
                  <a-input-password
                    v-model:value="formState.password"
                    placeholder="密码"
                  />
                </a-form-item>
                <div class="btn-group">
                  <span class="font-blue">海外手机号登录</span>
                  <span class="font-light">忘记密码</span>
                </div>
                <a-form-item :wrapper-col="{ span: 24 }">
                  <a-button type="primary" html-type="submit" class="submitBtn" @click="loginNormal"
                    >登录</a-button
                  >
                </a-form-item>
              </a-form>
            </a-tab-pane>
          </a-tabs>
          <div class="thirdPartyLogin">
            <div class="title-other">
              <div class="decorate-line"></div>
              <div>其他方式登录</div>
              <div class="decorate-line"></div>
            </div>
            <div class="thirdPartContainer">
              <div class="container-box">
                <span class="circle-bg">微信 </span>
                <span class="circle-bg">QQ </span>
                <span class="circle-bg">微博 </span>
              </div>
            </div>
            <div class="signContent-tip">
              未注册手机验证后自动登录，注册即代表同意相关协议
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive } from "vue";
import { loginAPI} from "@/api/login/index";
import { message } from 'ant-design-vue';
let activeKey = ref("1");
interface FormState {
  username: string;
  password: string;
}
interface CodeForm{
  phone:string,
  code:string,
}
const formState = reactive<FormState>({
  username: "",
  password: "",
});

const codeState = reactive<CodeForm>({
  phone:'',
  code:"",
})

async function loginNormal() {//<*************************

  let res: any = await loginAPI(formState);
  if (res.code === 0) {
     console.log(res.data);
     
    } else {
      message.error(res.msg)
    }
}

</script>

<style lang="scss" scoped>
.main-container {
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  background-color: #b8e5f8;
  background-image: url(https://static.zhihu.com/heifetz/assets/sign_bg.47eec442.png);
  background-repeat: no-repeat;
  background-size: cover;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-direction: column;
  flex-direction: column;
  height: 100vh;
  overflow: auto;
  width: 100%;
  .sign-container {
    width: 100%;
    height: calc(100% - 42px);
    min-height: 688px;
    text-align: center;
    display: flex;
    justify-content: space-evenly;
    flex-direction: column;
    align-items: center;
    padding: 40px;
    .sign-title {
      .bigTitle {
        font-family: bigTitle;
        font-size: 60px;
        color: #0461cf;
        letter-spacing: 6px;
        font-weight: bold;
      }
      .subtitle {
        font-size: 16px;
        color: rgba($color: #000000, $alpha: 0.65);
      }
    }
    .sign-form {
      width: 700px;
      background: #fff;
      flex: 1;
      display: flex;
      margin-top: 20px;
      .form-left {
        width: 332px;
        // padding: 30px 0 ;
        padding-top: 90px;
        .appTips {
          box-sizing: border-box;
          margin: 0;
          min-width: 0;
          color: #444444;
          font-size: 16px;
          font-weight: 600;
          line-height: 23px;
          font-size: 14px;
        }
        .tips {
          box-sizing: border-box;
          margin: 0;
          margin-top: 0px;
          margin-bottom: 0px;
          min-width: 0;
          margin-top: 8px;
          margin-bottom: 24px;
          color: #444444;
          font-size: 14px;
          line-height: 20px;
        }
        .Qrcode-content {
          height: 210px;
          display: flex;
          align-items: center;
          justify-content: space-evenly;
          flex-direction: column;
          width: 100%;
          .Qrcode-img {
            border-radius: 6px;
            height: 120px;
            width: 120px;
            padding: 8px;
            border: 1px solid #ebebeb;
            img {
              height: 100%;
              width: 100%;
            }
          }
        }
        .button-group {
          padding: 0 10px;
          display: flex;
          margin: 26px 0 22px;
          justify-content: center;
          .other-btn {
            border-radius: 30px;
            font-size: 12px;
            width: calc(33.3% - 10px);
          }
          .other-btn:not(:last-child) {
            margin-right: 8px;
          }
          :deep(.ant-btn) {
            padding: 0;
          }
        }
      }
      .form-right {
        flex: 1;
        padding: 20px;
        border-left: 1px solid #ddd;
        .loginForm {
          padding: 10px 0px;
          :deep(.ant-input,.ant-input-affix-wrapper ){
            border: 1px solid transparent;
            border-bottom-color: #d9d9d9;
          }
          :deep(.ant-input-affix-wrapper .ant-input) {
            border-bottom-color: transparent;
          }
          .ant-input:focus,
          .ant-input-focused,
          .ant-input-affix-wrapper:focus,
          .ant-input-affix-wrapper-focused {
            box-shadow: unset;
          }
          .ant-input-affix-wrapper{
            border: 1px solid transparent;
            border-bottom: 1px solid #d9d9d9;
          }
          .submitBtn {
            width: 100%;
            background-color: #0461cf;
            height: 36px;
          }
          .btn-group {
            display: flex;
            justify-content: space-between;
            margin-bottom: 20px;
            span {
              cursor: pointer;
              &:hover{
                 color: #76839b;
              }
            }
          }
          .codeIpt{
            position: relative;
            .font-blue{
              cursor: pointer;
              position: absolute;
              top: 50%;
              right: 10px;
              transform: translateY(-50%);
              &:hover{
                color: #76839b;
              }
            }
          }
        }
        .thirdPartyLogin {
          .title-other {
            display: flex;
            align-items: center;
            box-sizing: border-box;
            margin: 0;
            min-width: 0;
            margin: 0 24px 12px;
            .decorate-line {
              box-sizing: border-box;
              margin: 0;
              min-width: 0;
              border-top: 1px solid;
              border-top-color: currentcolor;
              border-color: #ebebeb;
              width: 124px;
            }
            div:nth-of-type(2) {
              box-sizing: border-box;
              margin: 0;
              margin-right: 0px;
              margin-left: 0px;
              min-width: 0;
              color: #999999;
              font-size: 12px;
              margin-left: 16px;
              margin-right: 16px;
              width: 72px;
              overflow: hidden;
              line-height: 17px;
              white-space: nowrap;
            }
          }
          .signContent-tip {
            font-size: 12px;
            line-height: 19px;
            color: #999;
            padding: 12px 24px 30px;
          }
          .thirdPartContainer {
            height: 60px;
            line-height: 60px;
            display: flex;
            align-items: center;

            .container-box {
              margin: auto;
              -webkit-transition: opacity 0.3s ease;
              transition: opacity 0.3s ease;
              width: 204px;
              display: flex;
              justify-content: space-between;
              .circle-bg {
                border-radius: 50%;
                -webkit-box-align: center;
                -ms-flex-align: center;
                -webkit-box-pack: center;
                -ms-flex-pack: center;
                align-items: center;
                background: #f6f6f6;
                cursor: pointer;
                display: -webkit-inline-box;
                display: -ms-inline-flexbox;
                display: inline-flex;
                height: 36px;
                justify-content: center;
                width: 36px;
              }
            }
          }
        }
      }
    }
  }
}
</style>
